<?php $this->beginBlock('block_nav'); ?>
<li><a href="/report/shop-sale">门店销售统计</a></li>
<li><a href="/report/shop-product-sale">销售产品明细</a></li>

<?php $this->endBlock(); ?>




<?php $this->beginBlock('block_script'); ?>
<script type="text/javascript">

    $(function () {

        $('.form_datetime').datepicker({
            autoclose: true,
            format: 'yyyy-mm-dd',
            language: 'zh-CN',
            todayBtn: 'linked',
            initialDate: new Date(),
            endDate: new Date()

        });



        $("#btn_submit").click(function () {
            var $btn = $(this).button('loading');
            $("#div_content").empty();
            var form = $('#form_search').serialize();


            $.post('/report/shop-sale',form,function(data){
                $btn.button('reset');
                if(data.code == 200){
                    viewHandle.showResult(data.data);
                }else{
                    alertError(data.msg);
                }

            },'json');

        });


    })


    var viewHandle = {
        showResult: function (shops) {

            $.each(shops,function (i,shop) {
                var html = '<div class="box box-danger">';
                html += '<div class="box-header with-border">';
                html += '<i class="fa fa-inbox"></i>';
                html += '<h3 class="box-title">'+shop.name_inside+'</h3>';
                html += '</div>';
                html += '<div class="box-body">';
                html += '<div class="table-responsive">';
                html += '<table class="table table-striped">';
                html += '<thead>';
                html += '<tr>';
                html += '<th>渠道</th>';
                html += '<th>金额</th>';
                html += '<th>数量</th>';
                html += '</tr>';
                html += '</thead>';
                html += '<tbody>';
                html += '<tr><td>ELE</td><td>'+shop.amt_ele+'</td><td>'+shop.qty_order_ele+'</td></tr>';
                html += '<tr><td>MT</td><td>'+shop.amt_mt+'</td><td>'+shop.qty_order_mt+'</td></tr>';
                html += '<tr><td>堂食</td><td>'+shop.amt_stay+'</td><td>'+shop.qty_order_stay+'</td></tr>';
                html += '<tr><td>外卖</td><td>'+shop.amt_delivery+'</td><td>'+shop.qty_order_delivery+'</td></tr>';
                html += '<tr><td>食云集</td><td>'+shop.amt_syj+'</td><td>'+shop.qty_order_syj+'</td></tr>';
                html += '</tbody>';
                html += '<tfoot>';
                html += '<tr><th>总计</th><th><span class="description-percentage text-red">'+shop.amt_total+'</span></th><th><span class="description-percentage text-red">'+shop.qty_total+'</span></th></tr>';
                html += '</tfoot>';
                html += '</table>';
                html += '</div>';
                html += '</div>';
                html += '</div>';
                $("#div_content").append(html);
            });


        }


    }



</script>
<?php $this->endBlock(); ?>


<?php $this->beginContent('@app/views/layouts/adminlte_comm.php'); ?>
    <section class="content-header">
        <h1>
            门店销售
            <small>单店单日销售查询</small>
        </h1>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <!-- left column -->
            <div class="col-md-12">
                <!-- general form elements -->
                <div class="box">
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form role="form" id="form_search">
                        <div class="box-body">
                            <input type="text" class="form-control form_datetime" id="start_date" name="start_date" placeholder="开始日期" readonly>
                            <input type="text" class="form-control form_datetime" id="end_date" name="end_date" placeholder="结束日期" readonly>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <button type="button" class="btn btn-danger pull-right" data-loading-text="Loading..." id="btn_submit">确定</button>
                        </div>
                    </form>
                </div>
                <!-- /.box -->
                <div id="div_content">

                </div>


            </div>

        </div>


    </section>
    <!-- /.content -->

<?php $this->endContent(); ?>



